import java.util.Comparator;
import java.util.Scanner;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.List;

public class fucksevendottwo
{

    public static void main(String args[]) {
        String flag;
        String tmpName;
        int tmpAge;
        Boolean tmpGender;
        String tmpStuNo;
        String tmpClazz;
        double tmpSalary;
        String tmpCompany;
        Company tmpRealCompany;
        Scanner reader = new Scanner(System.in);
        List<Person> personList;
        while (true) {
            flag = reader.next();
            if (flag == "s") {
                tmpName = reader.next();
                tmpAge = reader.nextInt();
                tmpGender = reader.nextBoolean();
                tmpStuNo = reader.next();
                tmpClazz = reader.next();
                personList.add(new Student(tmpName, tmpAge, tmpGender, tmpStuNo, tmpClazz));
            } else if (flag == "e") {
                tmpName = reader.next();
                tmpAge = reader.nextInt();
                tmpGender = reader.nextBoolean();
                tmpSalary = reader.nextDouble();
                tmpCompany = reader.next();
                if (tmpCompany == "null") {
                    tmpRealCompany = null;
                } else {
                    tmpRealCompany = new Company(tmpCompany);
                }
                personList.add(new Employee(tmpName, tmpAge, tmpGender, tmpSalary, tmpRealCompany));
            } else {
                break;
            }
        }
        Collections.sort(personList, new Comparator<Person>() {
            @Override
            public int compare(Person a, Person b) {
                int namecmp = a.name.compareTo(b.name);
                if (namecmp != 0) {
                    return namecmp;
                } else {
                    return a.age > b.age ? -1 : a.age == b.age ? 0 : 1;
                }
            }
        });
        flag = reader.next();
        if (flag == "exit") {
            return;
        }
        List<Student> stuList;
        List<Employee> empList;
        boolean used;
        for (Person person : personList) {
            used = false;
            for (Student student : stuList) {
                if (student.equals(person)) {
                    used = true;
                    break;
                }
            }
            for (Employee employee : empList) {
                if (employee.equals(person)) {
                    used = true;
                    break;
                }
            }
            if (person instanceof Student && !used) {
                stuList.add(person);
                continue;
            }
            if (person instanceof Employee && !used) {
                empList.add(person);
            }
        }
        System.out.println("stuList");
        for (Student student : stuList) {
            System.out.println(student);
        }
        System.out.println("empList");
        for (Employee employee : empList) {
            System.out.println(employee);
        }
    }
}

abstract class Person {
    String name;
    int age;
    boolean gender;

    public Person(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public String toString() {
        return name + "-" + Integer.toString(age) + Boolean.toString(gender);
    } // 返回"name-age-gender"格式的字符串

    public boolean equals(Object obj) {
        Person p = (Person) obj;
        if (p.name == null) {
            if (name != null) {
                return false;
            }
        }
        if (p.name == name) {
            if (p.age == age) {
                if (p.gender == gender) {
                    return true;
                }
            }
        }
        return false;
    } // 比较name、age、gender,都相同返回true,否则返回false
}

class Student extends Person {
    String stuNo;
    String clazz;
    public Student(String name, int age, boolean gender, String stuNo, String clazz) {
        super(name, age, gender);
        this.stuNo = stuNo;
        this.clazz = clazz;
    }

    public String toString() {
        return super.toString() + "-" + stuNo + "-" + clazz;
    }

    public boolean equals(Object obj) {
        if (super.equals(obj)) {
            Student s = (Student) obj;
            if (s.stuNo == null) {
                if (stuNo != null) {
                    return false;
                }
            }
            if (s.stuNo == stuNo) {
                if (s.clazz == null) {
                    if (stuNo != null) {
                        return false;
                    }
                }
                if (s.clazz == clazz) {
                    return true;
                }
            }
        }
        return false;
    }
}

class Company {
    String name;

    public Company(String name) {
        this.name = name;
    }

    public String toString() {
        return name;
    }

    public boolean equals(Object obj) {
        Company c = (Company) obj;
        if (c.name == null) {
            if (name != null) {
                return false;
            }
        }
        if (c.name == name) {
            return true;
        }
        return false;
    }
}

class Employee extends Person {
    Company company;
    double salary;

    public Employee(String name, int age, boolean gender, double salary, Company company) {
        super(name, age, gender);
        this.salary = salary;
        if (company != null) {
            this.company = company;
        } else {
            this.company = null;
        }
    }

    public String toString() {
        return super.toString() + "-" + company.toString() + "-" + Double.toString(salary);
    }

    public boolean equals(Object obj) {
        if (super.equals(obj)) {
            Employee e = (Employee) obj;
            if (e.company == null) {
                if (company != null) {
                    return false;
                }
            }
            if (e.company.equals(company)) {
                DecimalFormat df = new DecimalFormat("#.#");
                if (df.format(e.salary) == df.format(salary)) {
                    return true;
                }
            }
        }
        return false;
    }
}